import React from 'react'
import {Button, Icon,Popconfirm} from 'antd'

const hasAction = (action)=>{
    const all = new Set(allAction)
    return all.has(parseInt(action));
}

const getMenu=(menuArr, data)=>{
    return menuArr.map((item, index) => {
        if(hasAction(item.actionCode)){
            if(item.type) {
                return (
                    <Popconfirm title="你确定删除吗？" onConfirm={() => item.action(data)}>
                        <a title="删除"><Icon type={item.icon} style={item.style} /></a>
                    </Popconfirm>
                )
            }

            return (
                <a title={item.name} onClick={()=>item.action(data)} style={item.style} >{item.icon?<Icon type={item.icon} />:item.name}</a>
            )
        }
        
        return ""
    })
    
    
}



class ButtonList extends React.Component {
    state = {
        hidden:false
    }
    componentDidMount(){
    
        // console.log(this.props,allAction,'mybutton')
    }
    
    render(){
        const props = this.props;
        return (
           <div>
               {
                   getMenu(props.menuArr, props.data)
               }
           </div>
        )
    }
}

export default ButtonList 